#pragma once

// UserInterface class defines UI elements

#include "Scene.h"

const DWORD g_quitNoPrompt = MAKELPARAM(-1,-1);
const UINT g_msgEndModal = (WM_USER+100);

enum
{
	// Lower numbers get drawn first
	ZORDER_BACKGROUND, 
	ZORDER_LAYER1, 
	ZORDER_LAYER2, 
	ZORDER_LAYER3, 
	ZORDER_TOOLTIP
};


enum MessageBox_Questions {
	QUESTION_WHERES_THE_CD,
	QUESTION_QUIT_GAME,
};

class FontHandler;
class BaseUI;

// This class is a group of user interface controls.
// It can be modal or modeless.

//
// class BaseUI									- Chapter 10, page 286  
//
// This was factored to create a common class that
// implements some of the IScreenElement class common
// to modal/modeless dialogs
//
class BaseUI : public IScreenElement
{
protected:
	int					m_PosX, m_PosY;
	int					m_Width, m_Height;
	optional<int>		m_Result;
	bool				m_IsVisible;
public:
	BaseUI() { m_IsVisible = true; m_PosX = m_PosY = 0; m_Width = 100; m_Height = 100; }
	virtual void VOnUpdate(int) { };
	virtual HRESULT VOnLostDevice() { return S_OK; }
	virtual bool VIsVisible() const { return m_IsVisible; }
	virtual void VSetVisible(bool visible) { m_IsVisible = visible; }
};


//
// class ScreenElementScene						- Chapter X, page Y
//
class ScreenElementScene : public IScreenElement, public Scene
{
public:
	ScreenElementScene(boost::shared_ptr<IRenderer> renderer) : Scene(renderer) { }
    virtual ~ScreenElementScene()
    {
        PRINT_WARNING("~ScreenElementScene()");
    }

	// IScreenElement Implementation
	virtual void VOnUpdate(int deltaMS) { OnUpdate(deltaMS); };
	virtual HRESULT VOnRestore() 
		{ OnRestore(); return S_OK; }
	virtual HRESULT VOnRender(double fTime, float fElapsedTime)
		{ OnRender(); return S_OK; }
	virtual HRESULT VOnLostDevice()
		{ OnLostDevice(); return S_OK; } 
	virtual int VGetZOrder() const { return 0; }
	virtual void VSetZOrder(int const zOrder) { }

	// Don't handle any messages
	virtual LRESULT CALLBACK VOnMsgProc( AppMsg msg ) { return 0; }

	virtual bool VIsVisible() const { return true; }
	virtual void VSetVisible(bool visible) { }
	virtual bool VAddChild(ActorId id, boost::shared_ptr<ISceneNode> kid) { return Scene::AddChild(id, kid); }
};



